package com.linkhub.oms.admin.common.util;

import com.linkhub.oms.common.spring.QtApplicationContextHelper;
import org.springframework.context.MessageSource;
import org.springframework.context.i18n.LocaleContextHolder;

/**
 * @Description: 获取多语言消息
 * @Author: echo
 * @Date: 2024/3/3 16:43
 * @Version: 1.0
 */
public class I18nMessageUtil {


    /**
     * 获取国际化消息, 通过 {@link com.linkhub.oms.admin.config.i18n.I18nHeaderLocaleResolver} 解析前端传递的消息头
     *
     * @param key  配置文件的key
     * @param args 占位符参数
     * @return 国际化消息
     */
    public static String getMessage(String key, Object... args) {
        MessageSource messageSource = QtApplicationContextHelper.getBean(MessageSource.class);
        return messageSource.getMessage(key, args, LocaleContextHolder.getLocale());

    }
}
